package net.tavion.demo;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class BeanUtils extends org.apache.commons.beanutils.BeanUtils {
    static Logger logger=LoggerFactory.getLogger(BeanUtils.class);
    public BeanUtils() {
    }

    public static boolean isPrimitive(Class clz) {
        try {
            return ((Class) clz.getField("TYPE").get(null)).isPrimitive();
        } catch (Exception e) {
            return false;
        }
    }

    public static <T> T readToObject(String content, Class<T> valueType) {
        if (StringUtils.isBlank( content)) {
            return null;
        } else {
            try {
                return new  ObjectMapper().readValue(content, valueType);
            } catch (Exception var4) {
                logger.error(var4.getMessage(),var4);
                return null;
            }
        }
    }

    public static <T> String writeAsString(T object) {
        try {
            return new  ObjectMapper().writeValueAsString(object);
        } catch (Exception var3) {
            logger.error(var3.getMessage(),var3);
            return null;
        }
    }

}
